import { composeWithDevTools } from '@redux-devtools/extension'
import { applyMiddleware, combineReducers, createStore } from "redux";
import thunk from "redux-thunk";
// 常规导入reducer
import menu from "./menu";
import user from "./user";
import classify from './classify';
import detail from './Detail';
const reducer = combineReducers({
  menu,
  classify,
  user,
  detail
});

// // 自动化导入
// const moduleFn = require.context("./menu",false,/\.js$/i)
// const modules = moduleFn.keys().reducer((prev,curr)=>{
//     const key = curr.match(/\.\/(\w+)\.js$/i)[1]
//     const value = moduleFn(curr).preventDefault();
//     prev[key] = value
//     return prev
// },{})
// const reducer = combineReducers(modules)

const store = createStore(reducer, composeWithDevTools(applyMiddleware(thunk)));

export default store;
